﻿using MB.RuleBase.Common;
using Public;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Business
{
    public class Bpublic
    {
        public List<KeyValueModel> GetOrderTypeKVList()
        {
            try
            {
                List<KeyValueModel> result = new List<KeyValueModel>();
                DataSet ds= DatabaseExcuteByXmlHelper.NewInstance.GetDataSetByXml("public", "GetOrderType");
                if (ds != null && ds.Tables.Count > 0)
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        KeyValueModel kv = new KeyValueModel() { Key = dr["Head_Character"].ToString(), Value = dr["Related_number"].ToString() };
                        result.Add(kv);
                    }
                }
                return result;
            }
            catch (Exception ex)
            {
                MB.Util.TraceEx.Write(ex.Message);
                return null;
            }

        }

        public List<KeyValueModel> GetLookUpItemList(string LookUpID)
        {
            try
            {
                List<KeyValueModel> result = new List<KeyValueModel>();
                DataSet ds = DatabaseExcuteByXmlHelper.NewInstance.GetDataSetByXml("public", "getLookUpItemList", LookUpID);
                if (ds != null && ds.Tables.Count > 0)
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        KeyValueModel kv = new KeyValueModel() { Key = dr["FIELDVALUE"].ToString(), Value = dr["LOOKUP"].ToString() };
                        result.Add(kv);
                    }
                }
                return result;
            }
            catch (Exception ex)
            {
                MB.Util.TraceEx.Write(ex.Message);
                return null;
            }
        }
    }
}
